root.manage.validator = {
    form:"form-data",
    reset:"reset"
};

root.manage.validator.resetValidator = function(validator){
    $("#"+root.manage.validator.reset).on("click",function(){
        if(validator!==undefined) {
            validator.resetForm();
        };
    });
};
root.manage.login={};
root.manage.login.validate = function(){
    var $formContainer,validator;
    if(arguments.length==0){
        $formContainer = $("#"+root.manage.validator.form);
    }
    validator = $formContainer.validate({
        rules:{
            username:"required",
            password:"required"
        },
        messages:{
            username:"请输入用户名",
            password:"请输入密码"
        }
    });
    root.manage.validator.resetValidator(validator);
};

root.manage.article.validate = function(){
    var $formContainer,validator;
    if(arguments.length==0){
        $formContainer = $("#"+root.manage.validator.form);
    }
    validator = $formContainer.validate({
        rules:{
            title:"required",
            channelId:{min:1}
        },
        messages:{
            title:"请填写文章标题",
            channelId:{min:"请选择文章栏目"}
        }
    });
    root.manage.validator.resetValidator(validator);
};

root.manage.channel.validate = function(){
    var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            title:"required"
        },
        messages:{
            title:"请填写文章标题"
        }
    });
    root.manage.validator.resetValidator(validator);
};


root.manage.news.validate = function(){
    var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            title:"required",
            typeid:{required:true,min:1}
        },
        messages:{
            title:"请填写新闻标题",
            typeid:{required:"请选择新闻类型",min:"请选择新闻类型"}
        }
    });
    root.manage.validator.resetValidator(validator);
};

root.manage.productCategory.validate=function(){
	var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            name:"required",
            parent:{required:true,min:0}
        },
        messages:{
            name:"请填写名称",
            parent:{required:"请选择分类",min:"请选择分类"}
        }
    });
    root.manage.validator.resetValidator(validator);
};

root.manage.config.validate=function(){
	var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            webname:"required"
        },
        messages:{
            webname:"请填写网站名称"
        }
    });
    root.manage.validator.resetValidator(validator);
};

root.manage.photolink.validate=function(){
	var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            name:"required"
        },
        messages:{
            name:"请填写名称"
        }
    });
    root.manage.validator.resetValidator(validator);
};
root.manage.resource.validate=function(){
	var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            name:"required",
            identity:"required"
        },
        messages:{
            name:"请填写名称",
            identity:"请填写标识"
        }
    });
    root.manage.validator.resetValidator(validator);
};
root.manage.user.validate=function(){
	var formContainer,validator;
    if(arguments.length==0){
        formContainer = $("#"+root.manage.validator.form);
    }
    validator = formContainer.validate({
        rules:{
            username:"required"
        },
        messages:{
            name:"请填写用户名"
        }
    });
    root.manage.validator.resetValidator(validator);
};